package com.umpay.privi.common;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author 胡斌
 * 2013-4-27 肖明修改，使用泛型，避免强转
 */
public class BeanManager {
	
	private static ApplicationContext context = null;

	static {
		try {
			context = new ClassPathXmlApplicationContext("spring.xml");
		} catch (Exception e) {
			throw new RuntimeException("Description.  Cause: " + e, e);
		}

	}

	public static Object getBean(String beanName) {
		return context.getBean(beanName);
	}

	public static <T> T getBean(String beanName, Class<T> classname) {
		return (T)context.getBean(beanName, classname);
	}

}
